package com.cf.r1042_ak;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class a {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken();
        int t = (int) in.nval;
        while (t-- > 0) {
            in.nextToken(); int n = (int) in.nval;
            List<Integer> setadb = new ArrayList<>();
            List<Integer> setbda = new ArrayList<>();
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++) {
                in.nextToken(); a[i] = (int) in.nval;
            }
            for (int i = 0; i < n; i++) {
                in.nextToken(); b[i] = (int) in.nval;
                if (a[i] > b[i]) {
                    setadb.add(i);
                }
                if (b[i] > a[i]) {
                    setbda.add(i);
                }
            }
            int ans = 0;
            while (!setadb.isEmpty()) {
                ans++;
                Integer i = setadb.get(0);
                a[i]--;
                if (a[i] == b[i]) setadb.remove(0);
                if (!setbda.isEmpty()) {
                    Integer j = setbda.get(0);
                    a[j]++;
                    if (a[j] == b[j]) setbda.remove(0);
                }
            }
            out.println(ans + 1);
        }
        out.flush();
        out.close();
        br.close();
    }
}